#!/bin/sh
dns="www.baidu.com"

while true
do
  echo $(date +%F%n%T) Cheack ppp status
  flag=`ifconfig |grep ppp|wc -l`
  if [ $flag -eq 0 ]; then
    # 如果没有ppp进程，直接启动pppd拨号
    sudo bash /home/pi/linux-ppp-scripts/quectel-pppd.sh
    sleep 10
    
    #修改路由信息
    sudo route del default
    sudo route add default dev ppp0
  fi
  ping -I ppp0 -s 1 -c 1 $dns
  if [ "$?" != "0" ]; then
    echo ping not
    sudo bash /home/pi/linux-ppp-scripts/quectel-ppp-kill
  fi
  #5分钟检测一下
  sleep 60
done